package com.zhuhjay.controller;

import com.zhuhjay.domain.http.Result;
import com.zhuhjay.domain.dto.FileChunkDto;
import com.zhuhjay.service.FileStorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Zhuhjay
 * @since 2023-01-05
 */
@Slf4j
@RestController
@RequestMapping("/file")
public class FileStorageController {

    @Resource
    private FileStorageService storageService;

    @GetMapping("upload")
    public Result uploadCheck(FileChunkDto chunkInfo) {
        return Result.ok().beanToData(storageService.check(chunkInfo));
    }

    @PostMapping("upload")
    public Result upload(FileChunkDto chunkInfo) {
        return storageService.upload(chunkInfo);
    }

}
